import logging
import random
from rest_framework.permissions import BasePermission

from apps.authlab.models import UserInfo


class AdministratorRole(BasePermission):
    def has_permission(self, request, view) -> bool:
        logging.info(f"the view: {view}")
        username = request.user
        userinfo = UserInfo.objects.filter(username=username).first()
        logging.info(f"Username: {username}, userInfo: {userinfo}")
        v1 = random.randint(1, 3)
        logging.info(f"v1: {v1}")
        if v1 == 2:
            return True
        return False


class PublicRole(BasePermission):
    def has_permission(self, request, view):
        return True
    
